//
//  SubjectCell.m
//  ErWa
//
//  Created by 赵颜彬 on 16/3/9.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "SubjectCell.h"

@implementation SubjectCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.imgView = [[UIImageView alloc] init];
        [self.contentView addSubview:_imgView];
        _imgView.layer.cornerRadius = 5;
        _imgView.clipsToBounds = YES;
        // 图片按比例放置 不会失真
        _imgView.contentMode = UIViewContentModeScaleAspectFill;
        
        self.contentLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_contentLabel];
        _contentLabel.numberOfLines = 0;
        _contentLabel.font = [UIFont systemFontOfSize:15];
        
        self.likeLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_likeLabel];
        _likeLabel.textAlignment = NSTextAlignmentCenter;
        
        self.commentLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_commentLabel];
        _commentLabel.textAlignment = NSTextAlignmentCenter;
        
        self.likeImg = [[UIImageView alloc] init];
        [self.contentView addSubview:_likeImg];
        
        self.commentImg = [[UIImageView alloc] init];
        [self.contentView addSubview:_commentImg];
        
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    //图片
    self.imgView.frame = CGRectMake(20, 10, self.contentView.frame.size.width - 40, self.frame.size.height - self.frame.size.height / 4 - 40);
    //内容
    self.contentLabel.frame = CGRectMake( 20, _imgView.frame.origin.y + _imgView.frame.size.height + 5 , _imgView.frame.size.width, self.frame.size.height / 4);
    self.contentLabel.textColor = [UIColor grayColor];
    //评论
    self.commentImg.frame = CGRectMake(self.contentView.frame.size.width / 2, _contentLabel.frame.origin.y + _contentLabel.frame.size.height, self.contentView.frame.size.width / 20, self.contentView.frame.size.width / 20);
    self.commentLabel.frame = CGRectMake(_commentImg.frame.origin.x + _commentImg.frame.size.width, _commentImg.frame.origin.y, _commentImg.frame.size.width * 2, _commentImg.frame.size.height);
    //喜欢
    self.likeImg.frame = CGRectMake(_commentLabel.frame.origin.x + _commentLabel.frame.size.width, _commentImg.frame.origin.y, _commentImg.frame.size.width, _commentImg.frame.size.height);
    self.likeLabel.frame = CGRectMake(_likeImg.frame.origin.x + _likeImg.frame.size.width, _commentImg.frame.origin.y, _commentImg.frame.size.width * 2, _commentImg.frame.size.height);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
